import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
// import vueDevTools from 'vite-plugin-vue-devtools'
import legacy from '@vitejs/plugin-legacy'
import Inspect from 'vite-plugin-inspect'
import esbuild from 'rollup-plugin-esbuild'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { PluginOption, Plugin } from 'vite'
const esbuildPlugin = (): Plugin => ({
  ...esbuild({
    target: 'chrome64',
    include: /.vue/,
    loaders: {
      '.vue': 'js',
    },
  }),
  enforce: 'post'
})
export const plugins: PluginOption[] = [
  vue(),
  vueJsx(),
  // vueDevTools(),
  esbuildPlugin(),
  Inspect(),
  AutoImport({
    imports: ['vue', 'vue-router', 'pinia'],
    dts: '../../types/auto-imports.d.ts',
    resolvers: [ElementPlusResolver()],
    vueTemplate: true,
  }),
  Components({
    resolvers: [ElementPlusResolver()],
    dts: '../../types/components.d.ts'
  }),
  legacy()
]